<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>编辑员工</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="robots" content="noindex,nofollow" />
		<link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
		<link rel="stylesheet" href="__CSS__/common.css" media="all">
		<style>
			ul.layui-tab-title li::after {
      display: none;
    }

    ul.layui-tab-title li a::after {
      left: 20px !important;
    }
	.new-form .layui-form-checked span,.new-form .layui-form-checked:hover span {
		background-color: #fff!important;
	}
  </style>
	</head>

	<body class="page-body">
		<h2 class="comm-title">编辑员工</h2>
		
		<div class="tpcms-body-div page-main">
			<form class="layui-form new-form" id="admin">
				<div class="layui-form-item" id="clickInput">
					<label class="layui-form-label">员工类型</label>
					<div class="layui-input-block " >
						{volist name='$type' id='co' key='k'}
							<input type="checkbox" name="staff_type[{$co.id}]" value="{$co.id}" lay-filter="switchTest" {if(in_array($co.id,$info.staff_type))} checked {/if} lay-skin="primary"  title="{$co.name}" >
						{/volist}
					</div>
					<div class="layui-form-mid layui-word-aux">测量工程师和报价工程师不能同时选中</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">名称</label>
					<div class="layui-input-block">
						<input type="text" name="username" value="{$info.username}" lay-verify="required" placeholder="请输入名称" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">地址</label>
					<div class="layui-input-block">
						<input type="text" name="address" value="{$info.address}" lay-verify="required" placeholder="请输入地址" class="layui-input">
					</div>
				</div>
				<!-- <div class="layui-form-item">
					<label class="layui-form-label">预算</label>
					<div class="layui-input-block">
						<input type="text" name="budget" value="{$info.budget}" lay-verify="required|number" autocomplete="off" placeholder="请输入预算" class="layui-input">
					</div>
				</div> -->
				<div class="layui-form-item">
					<label class="layui-form-label">评价</label>
					<div class="layui-input-block">
						<input type="text" name="score" value="{$info.score}" lay-verify="required|number" autocomplete="off" placeholder="请输入评价数字" class="layui-input">
					</div>
				</div>
		</div>


		<input type="hidden" name="id" value="{$info.id}">
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="button" class="layui-btn new-btn-style" lay-submit lay-filter="admin">立即提交</button>
				<button type="button" class="layui-btn layui-btn-primary layui-btn-normal reset_pwd" title="初始密码为手机号" >重置密码</button>
				<!-- <button type="reset" class="layui-btn layui-btn-primary default-btn">重置</button> -->
			</div>
		</div>

		</form>


		<script src="__PUBLIC__/layui/layui.js"></script>
		<script src="__PUBLIC__/jquery/jquery.min.js"></script>

		<script>
			arr_box = {$json_type|raw};
			layui.use(['layer', 'form', 'layedit', 'upload'], function() {
				var layer = layui.layer,
					$ = layui.jquery,
					form = layui.form;
				
				$(".reset_pwd").click(function(){
				  layer.confirm('确定要重置?', function (index) {
				    $.ajax({
				      url: "{:url('reset_pwd')}",
				      data: { id: '{$info.id}' },
				      success: function (res) {
				        layer.msg(res.message, {
				        	offset: '15px',
				        	icon: 1,
				        	time: 1000
				        }, function() {
				        	window.parent.location.reload();
				        	varindex = parent.layer.getFrameIndex(window.name);
				        	parent.layer.close(index);
				        });
				      }
				    })
				  })
				});
				form.on('checkbox(switchTest)', function (data) {
				　　var wei = arr_box.indexOf(data.value);
					if(wei > -1){
						arr_box.splice(wei, 1);
					}
				    if( data.elem.checked){
						arr_box.push(data.value);
				    }
					if(arr_box.length > 1){
						if(arr_box.indexOf('6') > -1 || arr_box.indexOf('5') > -1){
							layer.msg('只能选择一个', {
								offset: '15px',
								icon: 2,
								time: 1000
							});
							return false ;
						}
					}
				});
				form.on('submit(admin)', function(data) {
					$.ajax({
						url: "{:url('edit')}",
						data: $('#admin').serialize(),
						type: 'post',
						success: function(res) {
							if (res.code == 0) {
								layer.msg(res.message, {
									offset: '15px',
									icon: 1,
									time: 1000
								}, function() {
									window.parent.location.reload();
									varindex = parent.layer.getFrameIndex(window.name);
									parent.layer.close(index);
								});
							} else {
								layer.msg(res.message, {
									offset: '15px',
									icon: 2,
									time: 1000
								});
							}
						}
					})
					return false;
				});
			});
		</script>
		</div>
	</body>

</html>
